/**
 * Notification  entity. Getters & setters.
 */
package com.xoomworks.rsfr.model;

import java.io.Serializable;
import java.util.Date;

/**
 * The persistent class for the notifications database table.
 *
 * @author andrea.ghisa
 */
public class Notification extends BaseEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    private Date createdOn;

    private Date modifiedOn;

    private String notificationBody;

    // uni-directional many-to-one association to TrustedCompany
    private TrustedCompany trustedCompany;

    private String notificationTitle;

    // uni-directional many-to-one association to User
    private User createdBy;

    // uni-directional many-to-one association to User
    private User modifiedBy;

    // uni-directional many-to-one association to Company
    private Company fromCompany;

    // uni-directional many-to-one association to Company
    private Company toCompany;

    // uni-directional many-to-one association to Notificationtype
    private NotificationType notificationType;

    // uni-directional many-to-one association to Notificationstate
    private NotificationState notificationState;

    // uni-directional many-to-one association to Trainingsession
    private TrainingSession trainingSession;

    // uni-directional many-to-one association to Requirement
    private Requirement requirement;

    // uni-directional many-to-one association to Resource
    private Resource resource;

    /**
     * Constructor with no fields.
     */
    public Notification() {
    }

    /**
     * Constructor with the specific parameters.
     *
     * @param createdOn
     *            Date Represents the date when notification was created.
     * @param notificationTitle
     *            String Represents the name of the notification.
     * @param createdBy
     *            User Represents the name of user who created the notification.
     * @param fromCompany
     *            Company Represents the company which created the notification.
     * @param toCompany
     *            Company Represents the company who received the notification.
     * @param notificationType
     *            NotificationType Represents the type of the notification(e.g
     *            New resource).
     * @param notificationState
     *            NotificationState Represents the state of the notification
     *            (e.g Pending, Received or Failed)
     * @param resource
     *            Resource Represents the resource available
     */
    public Notification(final Date createdOn, final String notificationTitle, final User createdBy,
            final Company fromCompany, final Company toCompany,
            final NotificationType notificationType, final NotificationState notificationState,
            final Resource resource) {
        super();
        this.createdOn = createdOn;
        this.notificationTitle = notificationTitle;
        this.createdBy = createdBy;
        this.fromCompany = fromCompany;
        this.toCompany = toCompany;
        this.notificationType = notificationType;
        this.notificationState = notificationState;
        this.resource = resource;
    }

    /**
     * Gets the current date.
     *
     * @return createdOn Date Represents the date when notification was created.
     */
    public Date getCreatedOn() {
        return this.createdOn;
    }

    /**
     * Sets the current date.
     *
     * @param createdOn
     *            Date Which is used to set the createdOn.
     */
    public void setCreatedOn(final Date createdOn) {
        this.createdOn = createdOn;
    }

    /**
     * Gets the date.
     *
     * @return modifiedOn Date Represents the date when the notification was
     *         modified.
     */
    public Date getModifiedOn() {
        return this.modifiedOn;
    }

    /**
     * Sets the date when the notification was modified.
     *
     * @param modifiedOn
     *            Date Which is used to set the modifiedOn.
     */
    public void setModifiedOn(final Date modifiedOn) {
        this.modifiedOn = modifiedOn;
    }

    /**
     * Gets the notification content.
     *
     * @return notoficationBody String Represents the content of the
     *         notification.
     */
    public String getNotificationBody() {
        return this.notificationBody;
    }

    /**
     * Sets the notification body.
     *
     * @param notificationBody
     *            String Which is used to set the notificationBody.
     */
    public void setNotificationBody(final String notificationBody) {
        this.notificationBody = notificationBody;
    }

    /**
     * Gets the name of the notification.
     *
     * @return notificationTitle String Represents the name of the notification.
     */
    public String getNotificationTitle() {
        return this.notificationTitle;
    }

    /**
     * Sets the title of the notification.
     *
     * @param notificationTitle
     *            Which is used to set the notificationTitle.
     */
    public void setNotificationTitle(final String notificationTitle) {
        this.notificationTitle = notificationTitle;
    }

    /**
     * Gets the user who created the notification.
     *
     * @return createdBy User Represents the user who created the notification
     */
    public User getCreatedBy() {
        return this.createdBy;
    }

    /**
     * Sets the user who created the notification.
     *
     * @param createdBy
     *            Which is used to set createdBy.
     */
    public void setCreatedBy(final User createdBy) {
        this.createdBy = createdBy;
    }

    /**
     * Gets the user who modified the notification.
     *
     * @return modifiedBy User Represents the user who modified the
     *         notification.
     */
    public User getModifiedBy() {
        return this.modifiedBy;
    }

    /**
     * Set the user who modified the notification.
     *
     * @param modifiedBy
     *            Which is used to set the modifiedBy.
     */
    public void setModifiedBy(final User modifiedBy) {
        this.modifiedBy = modifiedBy;
    }

    /**
     * Gets the company from where user who created the company belongs.
     *
     * @return fromCompany Company Represents the company which created the
     *         notification.
     */
    public Company getFromCompany() {
        return this.fromCompany;
    }

    /**
     * Sets the company from where user who created the company belongs.
     *
     * @param fromCompany
     *            Company Which is used to set fromCompany.
     */
    public void setFromCompany(final Company fromCompany) {
        this.fromCompany = fromCompany;
    }

    /**
     * Gets the company who received the notification.
     *
     * @return toCompany Company Represents the company who received the
     *         notification.
     */
    public Company getToCompany() {
        return this.toCompany;
    }

    /**
     * Sets the company who received the notification.
     *
     * @param toCompany
     *            Company Which is used to set the toCompany.
     */
    public void setToCompany(final Company toCompany) {
        this.toCompany = toCompany;
    }

    /**
     * Gets the type of the notification.
     *
     * @return norificationType Represents the type of the notification.
     */
    public NotificationType getNotificationType() {
        return this.notificationType;
    }

    /**
     * Sets the type of the notification.
     *
     * @param notificationType
     *            NotificationType which is used to set the notificationType.
     */
    public void setNotificationType(final NotificationType notificationType) {
        this.notificationType = notificationType;
    }

    /**
     * Gets the state of the notification.
     *
     * @return notificationState Represents the state of the notification.
     */
    public NotificationState getNotificationState() {
        return this.notificationState;
    }

    /**
     * Sets the state of the notification.
     *
     * @param notificationState
     *            NotificationState Which is used to set the notidicationState.
     */
    public void setNotificationState(final NotificationState notificationState) {
        this.notificationState = notificationState;
    }

    /**
     * Gets the training session on which resource participated.
     *
     * @return trainingSession TrainingSession Represents session on which
     *         resource participated.
     */
    public TrainingSession getTrainingSession() {
        return this.trainingSession;
    }

    /**
     * Sets training session.
     *
     * @param trainingSession
     *            TrainingSession Which is used to set trainingSession.
     */
    public void setTrainingSession(final TrainingSession trainingSession) {
        this.trainingSession = trainingSession;
    }

    /**
     * Gets the requirement from the company.
     *
     * @return requirement Requirement Represents the requirement from the
     *         company.
     */
    public Requirement getRequirement() {
        return this.requirement;
    }

    /**
     * Sets the requirement.
     *
     * @param requirement
     *            Requirement Which is used to set the requirement.
     */
    public void setRequirement(final Requirement requirement) {
        this.requirement = requirement;
    }

    /**
     * Gets the resource from the notification body.
     *
     * @return resource Resource Represents the resource from the notification
     *         body.
     */
    public Resource getResource() {
        return this.resource;
    }

    /**
     * Sets the resource.
     *
     * @param resource
     *            REsource Which is used to set the resource.
     */
    public void setResource(final Resource resource) {
        this.resource = resource;
    }

    /**
     * Gets an trusted company.
     *
     * @return trustedCompany TrustedCompany Represents an trusted company
     */
    public TrustedCompany getTrustedCompany() {
        return trustedCompany;
    }

    /**
     * Sets the trusted company.
     *
     * @param trustedCompany
     *            TrustedCompany Which is used to set the trustedCompany.
     */
    public void setTrustedCompany(final TrustedCompany trustedCompany) {
        this.trustedCompany = trustedCompany;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((notificationBody == null) ? 0 : notificationBody.hashCode());
        result = prime * result + ((notificationState == null) ? 0 : notificationState.hashCode());
        result = prime * result + ((notificationTitle == null) ? 0 : notificationTitle.hashCode());
        result = prime * result + ((notificationType == null) ? 0 : notificationType.hashCode());
        return result;
    }

    @Override
    public boolean equals(final Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        Notification other = (Notification) obj;
        if (notificationBody == null) {
            if (other.notificationBody != null) {
                return false;
            }
        } else if (!notificationBody.equals(other.notificationBody)) {
            return false;
        }
        if (notificationState == null) {
            if (other.notificationState != null) {
                return false;
            }
        } else if (!notificationState.equals(other.notificationState)) {
            return false;
        }
        if (notificationTitle == null) {
            if (other.notificationTitle != null) {
                return false;
            }
        } else if (!notificationTitle.equals(other.notificationTitle)) {
            return false;
        }
        if (notificationType == null) {
            if (other.notificationType != null) {
                return false;
            }
        } else if (!notificationType.equals(other.notificationType)) {
            return false;
        }
        return true;
    }

}
